<template>
  <el-tree :data="categoryList" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
</template>

<script>
  import {listCategory} from "@/api/product/category";

  export default {
    data() {
      return {
        // 商品分类表格数据
        categoryList: [],
        defaultProps: {
          children: 'children',
          label: 'name'
        }
      };
    },
    created() {
      this.getList();
    },
    methods: {
      /** 查询商品分类列表 */
      getList() {
        this.loading = true;
        listCategory(this.queryParams).then(response => {
          this.categoryList = this.handleTree(response.rows, "catId", "parentCid");
        });
      },
      handleNodeClick(data,node,component) {
        this.$emit('tree-node-click',data,node,component)
      }
    }
  };
</script>

<style scoped>

</style>
